#include "../include/cameraDrv.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static pCameraObj pHead = NULL;


pCameraObj cameraFind(char* name)
{
    printf("camerafind.\r\n");
    pCameraObj pcObj = pHead;
    
    while(pcObj != NULL)
    {
        if(!strcmp(pcObj->name,name))
        {
            return pcObj;
        }
        else
        {
            pcObj = pcObj->next;
        }
    }
    return NULL;
}

unsigned int cameraWrite(pCameraObj obj,void* data)
{
    return obj->cameraObjOpt->write(data);
}

unsigned int cameraRead(pCameraObj obj,void* data)
{
    return obj->cameraObjOpt->read(data);
}

unsigned int cameraDeviceInit(pCameraObj obj)
{
    return obj->cameraObjOpt->init();
}

unsigned int cameraRegister(pCameraObj obj)
{
        printf("cameraRegister.\r\n");

        if(pHead == NULL)
        {
            pHead = obj;
            obj->next = NULL;
        }
        else
        {
            obj->next = pHead;
            pHead = obj;
        }
        return 0;
}


